package com.buss.util.http;

import org.apache.http.client.HttpClient;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;

/**
 * HttpClient 采用单例模式,重用实例
 * 
 * @author bin
 *
 */
public final class HttpClientUtil {

	private static DefaultHttpClient httpClient = null;

	private HttpClientUtil(){}
	
	public static synchronized HttpClient getHttpClient() {
        if(httpClient == null) {
        	/*ThreadSafeClientConnManager manager = new ThreadSafeClientConnManager();
        	manager.setMaxTotal(100);*/
           //线程安全管理 ThreadSafeClientConnManager
           httpClient = new DefaultHttpClient(
       			new ThreadSafeClientConnManager()); 
        	/*httpClient = new DefaultHttpClient(
           			manager); */
       }  
       return httpClient;
     }
	
}
